<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的购物车  - ${web.name}${web.additionalTitle!}</title>
<link href="${root}/css/global.css" type="text/css" rel="stylesheet" />
<link href="${root}/css/layout.css" type="text/css" rel="stylesheet" />
<link href="${root}/css/checkout.css" type="text/css" rel="stylesheet" />
<link href="${root}/css/member.css" type="text/css" rel="stylesheet" />
<link href="${root}/css/buy.css" type="text/css" rel="stylesheet" />
<link href="${root}/css/cart.css" type="text/css" rel="stylesheet" />
<script src="${root}/js/jquery.js" type="text/javascript"></script>
<script src="${root}/js/cart_sure.js"  type="text/javascript"></script>
<script type="text/javascript">
var URLPrefix = {
		"url":"${base}"
};
$(function() {
	$("#jvForm").validate();
});


//获得城市
function getResultCity(d){
	$.post('${base}/shopMemberAddress/findAllCity.jspx', {"id":d}, 
		function(data) {
					if(data.success){
						$("#itemcity").html("");
                         var select="<select name='cityId' onchange='getResultCountry(this.value)'>";
                        for(var i=0;i<data.ids.length;i++){
              				select+="<option value='"+data.ids[i]+"'>&nbsp;"+data.citys[i]+"&nbsp;</option>";
              			}
              			select+="</select>";
              			getResultCountry(data.ids[0]);
              			$("#itemcity").append(select);
					} 
	 },"json");
}
//获得县、区
function getResultCountry(a){
	$.post('${base}/shopMemberAddress/findAllCountry.jspx', {"id":a},
		 function(data) {
				if(data.success){
					$("#itemarea").html("");
                     var select="<select name='countryId'>";
                      for(var i=0;i<data.ids.length;i++){
              				select+="<option value='"+data.ids[i]+"'>&nbsp;"+data.areas[i]+"&nbsp;</option>";
              		 }
              		select+="</select>";
              		$("#itemarea").append(select);
				} 
		},"json");
}

function checkSubmit(){
	if($("#provinceId").val()==''||$("#provinceId").val()==null){
           alert("请选择所在地址!");
           return;
	}
	if($("#tel").val()==null&&$("#phone").val()==null&&$("#tel").val()==''&&$("#phone").val()==''){
        alert("手机跟电话至少有一项必填");
        return;
	}
	$("#jvForm").attr("action","${base}/shopMemberAddress/address_save.jspx");
	$("#jvForm").submit();
}
function checkSubmit1(){
	if($("input[name='deliveryInfo']").length<=0){
     alert("请添加邮寄地址");
     return;
	} 
	$("#addrInputDiv").html('');
	$("#jvForm").attr("action","create_exchange.jspx");
	$("#jvForm").submit();
}
</script>
</head>
<body>
[#include "../include/页头顶栏.html"/]
<div id="head">
	 [#include "../include/页头搜索栏.html"/]
    [#include "../include/页头导航栏.html"/]
</div>
<div class="w960">
<div id="topcolumn"></div>
<div class="buy_position">您当前的位置：<a href="" target="_blank">首页</a>&nbsp;&gt;&nbsp;礼品兑换</div>
<div id="checkoutUI" class="mt10">
   <div id="errorMsgDisplayDiv" style="z-index:1000;"></div>
    <form id="jvForm" action="create_exchange.jspx" method="post">
       <div id="receiver_buffer_window" class="delivery mb10">
        <div class="title"><h2>收货地址</h2> </div>
        
        <div id="inputUI_rece" class="rece_box">
	         <p class="adds_btn" id="btn_away_ui">&nbsp;</p>
	          [#if smalist?size gt 0]
                 [#list smalist as sma]
	              <p class="adds_list adds_selected">
	               <label class="pointer">
	                 <input type="radio" name="deliveryInfo" class="delivery_info" value="${sma.id}" 
	                 [#if sma.isDefault]checked="checked"[/#if]"/>
	                  <span class="text" style="position:relative">
	                   ${sma.username!}&nbsp;${sma.province.name!}&nbsp;${sma.city.name!}
	                    &nbsp;${sma.detailaddress!}&nbsp;${sma.tel!}&nbsp;&nbsp;&nbsp;&nbsp;
	                  <a href="${base}/shopMemberAddress/address_delete.jspx?id=${sma.id}&returnUrl=../exchange.jspx?id=${gift.id!}&count=${count!}" class="w44">删除|</a>
                      <a href="${base}/shopMemberAddress/address_default.jspx?id=${sma.id}&returnUrl=../exchange.jspx?id=${gift.id!}&count=${count!}">设为默认</a>
	                 </span>
	              </label>
	             </p>
	           [/#list]
              [/#if]
        <p class="add_adds">
         <span class="btn_span" onclick="jQuery('#addrInputDiv').show();">添加新地址</span>
         <span class="btn_span" onclick="jQuery('#addrInputDiv').hide();">取消新地址</span>
       </p>
        <hr class="delivery_hr" />
            <div id="addrInputDiv" class="adress_edit2 none">
                  <h3 class="h3">请填写收货人信息：</h3>
                   <p class="info_form">
                     <label for="user_name" class="lab"><em>*</em>收&nbsp;货 &nbsp;人：</label>
                       <input type="text" id="receiverName" name="username" class="user_name text required" />
                       <span id="nameError" class="prompt"></span>
                   </p>
                   <p class="info_form">
                     <label for="user_name" class="lab"><em>*</em>性&nbsp;&nbsp;&nbsp;&nbsp;别：</label>&nbsp;
                     <input type="radio" name="gender" value="true" checked/>男&nbsp;&nbsp;&nbsp;&nbsp;
		             <input type="radio" name="gender" value="false"/>女
                   </p>
                   <p class="info_form">
                     <label for="select_province" class="lab"><em>*</em>收货地址：</label>
                      <select id="provinceId" name="provinceId" onchange="getResultCity(this.value)"  >
	                      <option value="">--请选择--</option>
	                      [#list plist as province]
		                       <option value="${province.id!}">${province.name!}</option>
                          [/#list]
                        </select>
                      <span id="itemcity"></span>
                      <span id="itemarea"></span>
                  </p>
                   <p class="info_form">
                      <label for="user_adress" class="lab"><em>*</em>详细地址：</label>
                      <input id="detailAddress" name="detailaddress" class="user_adress text required" type="text" />
                  </p>
                   <p class="info_form">
                      <label for="user_adress" class="lab"><em>*</em>邮政编码：</label>
                      <input id="postCode" name="postCode" class="user_phone text required digits" type="text" />
                  </p>
                  <p class="info_form">
                       <label for="user_phone" class="lab">手机号码：</label>
                       <input type="text" id="tel" name="tel" class="user_phone text digits"  />
                       <span id="mobileError" class="prompt">手机或电话必填一种</span>
                 </p>
                  <p class="info_form">
                       <label for="user_phone" class="lab"> 固定电话：</label>
                        <input type="text"  id="areaCode" name="areaCode"  size="4"  maxlength="4" class="user_areaCode text digits"/>-
		                <input type="text" id="phone" name="phone"  size="14" maxlength="10" class="user_phone text digits"/>-
		               <input  type="text" id="extNumber" name="extNumber"  size="6"  maxlength="6" class="user_extNumber text digits"/>
		                                     区号(3到4位数字，可选)-电话号码(7到8位数字)-分机号(最多6位数字，可选)
                 </p>
               <p class="info_form">
                      <input type="checkbox" onclick="$('#isDefault').val(this.checked)"/>
                      <input type="hidden" id="isDefault" name="isDefault" value="false"/>
                     <label for="daily_address">设为默认地址</label>
              </p>
              <p class="btn" id="addrSubBtn">
              <input type="hidden" name="returnUrl" value="../exchange.jspx?id=${gift.id!}&count=${count!}"/>
            <input type="button" value="保存收货信息"  onclick="checkSubmit();" />
            </p>
           </div>
   </div>
 </div>


  <div id="delivery_buffer_window" class="delivery mb10">
   <div class="title"><h2>礼品信息</h2></div>
   <div class="delivery_box" id="inputUI_delivery">
     
    <table>
        <tr class="head">
            <td width="180"></td>
            <td width="320">礼品名称</td>
            <td width="140" align="center">数 量</td>
            <td width="140" align="center">积 分</td>
            <td width="160" align="center">积分小计</td>
        </tr>
    <tr class="body">
        <td width="180"><img src="${gift.giftPicture!}" width="60" height="60"/></td>
        <td width="320">${gift.giftName!}</td>
        <td width="140" align="center">${count!}</td>
        <td width="140" align="center">${gift.giftScore!}</td>
        <td width="160" align="center">${totalScore!}</td>
    </tr>
</table>

</div>
</div>  

<div class="delivery_box" id="inputUI_delivery">
    <input type="hidden" name="count" value='${count!}'/>
    <input type="hidden" name="id" value='${gift.id!}'/>
    <p class="btn"><input type="button" id="confirm_delivery" value="提交" onclick="checkSubmit1();" /></p>
 </div>
</form>
</div>
</div>
[#include "../include/footer_information_bar.html"/]
</body>
</html>
